#include <iostream>
#include <vector>

using namespace std;
class Solution
{
public:
    int countSegments(string s)
    {
        int segmentCount = 0;

        for (int i = 0; i < s.length(); i++)
        {
            if ((i == 0 || s[i - 1] == ' ') && s[i] != ' ')
            {
                segmentCount++;
            }
        }
        return segmentCount;
    }
};
int main()
{
    Solution s;
    cout << s.countSegments("Hello, my name is John") << endl;
    return 0;
}
